package com.xiyu.service.controller.admin.restaurant;
import com.xiyu.service.vo.restaurant.plan.PlanGetOutput;
import com.xiyu.service.vo.restaurant.plan.PlanUpdateStatusInput;
import com.xiyu.service.vo.restaurant.plan.PlanUpdateInput;
import com.xiyu.service.vo.restaurant.plan.PlanCreateInput;
import com.xiyu.service.vo.restaurant.plan.PlanQueryOutput;
import com.xiyu.service.vo.restaurant.plan.PlanQueryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.restaurant.PlanService;

@Tag(name = "计划管理")
@RestController
@RequestMapping("/restaurant/plan")
@Validated
public class PlanController {

    @Resource
    private PlanService planService;

    @GetMapping("/query")
    @Operation(summary = "分页查询计划")
    @PreAuthorize("@ss.hasPermission('restaurant:plan:query')")
    public CommonResult<PageResult<PlanQueryOutput>> query(@Valid PlanQueryInput inputVO) {
        return success(planService.query(inputVO));
    }

    @PostMapping("/create")
    @Operation(summary = "新建计划")
    @PreAuthorize("@ss.hasPermission('restaurant:plan:create')")
    public CommonResult<Long> create(@Valid @RequestBody PlanCreateInput inputVO) {
        return success(planService.create(inputVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新计划")
    @PreAuthorize("@ss.hasPermission('restaurant:plan:update')")
    public CommonResult<Boolean> update(@Valid @RequestBody PlanUpdateInput inputVO) {
        return success(planService.update(inputVO));
    }

    @DeleteMapping("/deleted")
    @Operation(summary = "删除计划")
    @PreAuthorize("@ss.hasPermission('restaurant:plan:deleted')")
    @Parameter(name = "id", description = "主键ID", example = "")
    public CommonResult<Boolean> deleted(@RequestParam("id") Long id) {
        return success(planService.deleted(id));
    }

    @PostMapping("/update-status")
    @Operation(summary = "更新计划状态")
    public CommonResult<Boolean> updateStatus(@Valid @RequestBody PlanUpdateStatusInput inputVO) {
        return success(planService.updateStatus(inputVO));
    }

    @GetMapping("/get")
    @Operation(summary = "获取单个餐饮计划")
    @Parameter(name = "id", description = "主键ID", example = "")
    public CommonResult<PlanGetOutput> get(@RequestParam("id") Long id) {
        return success(planService.get(id));
    }

}
